﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Autofac;
using Autofac.Integration.Mvc;
using LX.Web.Mvc.SafeCode;
using LX.Web.Security;
using S4Store.Service;
using System.Reflection;
using S4Store.Persistent;

namespace S4Store.DI
{
    public class ServiceModule : Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            //builder.RegisterGeneric(typeof(LX.Core.Validation.ValidExpression<>)).PropertiesAutowired();
            builder.RegisterType<S4StoreDataContext>();
            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(Transtion))).Except<Transtion>().PropertiesAutowired();
            builder.RegisterType<SessionSafeCodeManager>().As<ISafeCodeProvider>();
            builder.RegisterControllers(Assembly.GetAssembly(typeof(SecurityController))).PropertiesAutowired();
            builder.RegisterControllers(Assembly.GetExecutingAssembly()).PropertiesAutowired();
            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces();
        }
    }
}